#coding:utf-8
from django.db import models 
from django.utils import timezone
from django.contrib.auth.models import User

class BlogArticles(models.Model):
    title = models.CharField(max_length=300) #标题 字段限制300
    author = models.ForeignKey(User,related_name="blog_posts")  #一个用户对应多篇文章
    body = models.TextField() 
    publish = models.DateTimeField(default=timezone.now)
    
    class Meta:
        ordering = ("-publish",) #文章按照publish倒序显示
    def __str__(self):
        return self.title
